<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<script>

    // function Student(name) {
    //     this.name = name;
    // }
    //
    // //给Student新增一个方法
    // Student.prototype.hello = function () {
    //     alert('hello')
    // };

    //ES6之后
    //定义一个学生的类
    class Student {
        constructor(name) {
            this.name = name;
        }

        hello() {
            alert('hello')
        }
    };

    class XiaoStudent extends Student {
        constructor(name,grade) {
            super(name);
            this.grade = grade;
        }

        myGrade(){
            alert('我是一名小学生')
        }
    };

    var xiaoming = new Student("xiaoming");
    var xiaohong = new xiaoStudent("xiaohong",1);

    // var xiaoming = new Student(xiaoming);
    // var xiaohong = new Student(xiaohong);
    // xiaoming.hello()

</script>


</body>
</html>